package com.le.tester.imooc.masterJUC.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 描述：线程池中创建固定的线程数,队列中增加的数目比线程处理的速度快,队列是存储信息，是需要消耗内存的，让这个内存占满
 * -Xms，初始化内存栈的大小
 * -Xmx，最大的内存数
 */
public class FixedThreadPoolOOMTester {
    public void f() {
        ExecutorService executorService = Executors.newFixedThreadPool(1);
        for (int i = 0; i < Integer.MAX_VALUE; i++) {
            executorService.execute(new SubThread());
        }
    }
}

class SubThread implements Runnable {
    @Override
    public void run() {
        try {
            Thread.sleep(Integer.MAX_VALUE);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}
